package com.sherlocky.learning.java11.time;

import java.time.Duration;
import java.util.concurrent.TimeUnit;

/**
 * 时间转换（舍去不足的部分）
 * @author: zhangcx
 * @date: 2019/9/26 16:52
 */
public class TimeSample {
    public static void main(String[] args) {
        long day = TimeUnit.DAYS.convert(Duration.ofHours(24));
        System.out.println(day == 1);

        // 1 天
        System.out.println(TimeUnit.DAYS.convert(Duration.ofHours(23)));
        System.out.println(TimeUnit.DAYS.convert(Duration.ofHours(24)));
        System.out.println(TimeUnit.DAYS.convert(Duration.ofHours(26)));

        // 1 分钟
        System.out.println(TimeUnit.MINUTES.convert(Duration.ofSeconds(60)));
    }
}
